<template>
  <div style="text-align:center">

    <div id="programme" style="width:790px;margin:auto;" ref="print">
      <shctTemplate></shctTemplate>
    </div>
    <div class="error500-btn-con ">
      <el-button @click="myprint " style="width: 200px;margin-top:10px " type='primary'>打印</el-button>
    </div>
  </div>
</template>
<script>
import { getObj } from '@/api/cust/health/shct'
import shctTemplate from './shctTemplate'
import html2canvas from 'html2canvas'
export default {
  name: 'xcgct',
  components: {
    shctTemplate
  },
  data() {
    return {
      grjbxxid: '',
      jktjid: '',
      sfzh: '',
      data: []
    }
  },
  created() {
    this.grjbxxid = this.$route.query.grjbxxid
    this.jktjid = this.$route.query.id
    this.sfzh = this.$route.query.sfzh
    this.getObj()
  },
  mounted() {},
  methods: {
    getObj() {
      getObj({
        jktjid: this.jktjid,
        grjbxxid: this.grjbxxid,
        jktjsfzh: this.sfzh
      }).then(res => {
        this.data = res.data.data
      })
    },
    myprint() {
      this.loading = true
      this.$print(this.$refs.print)
      this.loading = false
    }
  },
  computed: {
    allData() {
      var newData = this.data
      if (this.data.length > 9) {
        var arr = this.data.slice(9, this.data.length - 1)
        newData = this.data.slice(0, 9)
        for (var i = 0; i < arr.length; i++) {
          newData[i].xmmc1 = arr[i].xmmc
          newData[i].jieguo1 = arr[i].jieguo
          newData[i].ckz1 = arr[i].ckz
          newData[i].danwei1 = arr[i].danwei
        }
      }
      return newData
    }
  },
  props: []
}
</script>